-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds validator qgb checks #137
feat: Adds validator qgb checks #137
Conversation
44be9c7
to
b6fbf3a
Compare
…ecks # Conflicts: # client/flags/flags.go # simapp/simd/cmd/testnet.go # x/staking/simulation/operations.go
580e41c
to
0ff3aed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
simapp/helpers/test_helpers.go
Outdated
@@ -14,7 +14,7 @@ import ( | |||
|
|||
// SimAppChainID hardcoded chainID for simulation | |||
const ( | |||
DefaultGenTxGas = 1000000 | |||
DefaultGenTxGas = 4000000 // An increase is needed when adding checks to staking/msg_server.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a 2.6x increase in gas for couple fields and few checks doesn't look so right to me. What do you think?
@evan-forbes When you have time, please take a look on: https://github.com/celestiaorg/cosmos-sdk/runs/6333164562?check_suite_focus=true why it is failing. I can't understand why the app hash changes while running the same app. |
The app hash isn't just different, it's not even valid hex!
|
if msg.Orchestrator != "" { | ||
_, err := k.validateOrchestratorAddress(ctx, msg.Orchestrator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to error when a validator exists if you're trying to edit it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to have duplicate orchestrator or Ethereum address. If some other validatore has that address, we shouldnt continue. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For inserting a new validator, yes. But editing a validator (not sure what that even means?) requires the validator to exist prior to being edited, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We look first if the validator exists by its address. Then, we start checking if the new orchestrator address has been given to some other validator.
So, that one is looking for a validator by orchestrator address. If any other validator has that orchestrator address, we stop.
Or I am missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense, we want to throw an error if someone is trying to update their vaildator with an invalid orchestrator address. If we don't, then we won't be able to verify their attestations, and while it wouldn't be protocol breaking, I think it would be a terrible UX, as they'd have to debug why they can't submit signatures.
we're also checking that the validator exists on line 143
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commits are for debugging purposes (mainly commenting code to find the problematic change). The history will be cleaned with a force push.
x/staking/simulation/operations.go
Outdated
@@ -146,7 +148,9 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k | |||
simtypes.RandomDecAmount(r, maxCommission), | |||
) | |||
|
|||
ethAddr, _ := types.NewEthAddress("0x91DEd26b5f38B065FC0204c7929Da6b2A21277Cd") | |||
ethPrivateKey, _ := crypto.GenerateKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably what's making the app hash fail. Investigating more.
…mulation to have a deterministic way of creating it
a40e31b
to
fd79550
Compare
@evan-forbes If you agree on the eth address fix. we can merge. |
x/staking/simulation/operations.go
Outdated
ethAddr, _ := types.NewEthAddress("0x" + fmt.Sprintf("%X", doubleOrchAddressBytes[:(types.ETHContractAddressLen/2)-2])) | ||
ethAddr, _ := types.NewEthAddress("0x" + fmt.Sprintf("%X", doubleOrchAddressBytes[:(types.ETHContractAddressLen/2)-1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evan is confused why we are making doubleOrchAddress
in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and perhaps we should not be using the golang's hex formatting tooling, and instead be using geth's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. fix coming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and perhaps we should not be using the golang's hex formatting tooling, and instead be using geth's
It is the same. Just creating a hex string from a bytes array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check now again please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a quick sync with @sweexordious, the main issue is simply that we are randomly generating the address each time, which cause the non-determinism issue. It also doesn't help that the gravity bridge code uses their own custom type for an eth address instead of using a wrapper around geth's Address
type.
@sweexordious is currently writing an issue or two with a bit more context. With those reminders in place, I'm comfortable with merging, as we might not even use this method to keep track of orchestrator/eth addresses, so making another huge PR(s) just to properly fix the tests seems wasteful atm.
great work debugging @sweexordious !!
* first pass on tests fixes * fixes the rest of unit tests * remove unnecessary comments * uses default eth address when starting sim network * cosmetics * comments failing test * comments failing test * adds orchestrator/ethereum address checks for validators when creating and editing * uses correct error codes for eth/orch address errors * uncomments test and fixes it from commit 434b308 * adds zero eth address check when creating/updating validator * attempts to fix duplicate eth address in sim network * revert squashed changes * uses unwrapped context for msg_server orch/eth validation * increase DefaultGenTxGas to accomodate new qgb validator changes * scaffolds an ethereum address from orchestrator address in staking simulation to have a deterministic way of creating it * fix eth address creation from orch address in operations * increase DefaultGenTxGas * increase DefaultGenTxGas * simpler way of creating an eth address from orch address in operations
* first pass on tests fixes * fixes the rest of unit tests * remove unnecessary comments * uses default eth address when starting sim network * cosmetics * comments failing test * comments failing test * adds orchestrator/ethereum address checks for validators when creating and editing * uses correct error codes for eth/orch address errors * uncomments test and fixes it from commit 434b308 * adds zero eth address check when creating/updating validator * attempts to fix duplicate eth address in sim network * revert squashed changes * uses unwrapped context for msg_server orch/eth validation * increase DefaultGenTxGas to accomodate new qgb validator changes * scaffolds an ethereum address from orchestrator address in staking simulation to have a deterministic way of creating it * fix eth address creation from orch address in operations * increase DefaultGenTxGas * increase DefaultGenTxGas * simpler way of creating an eth address from orch address in operations
* first pass on tests fixes * fixes the rest of unit tests * remove unnecessary comments * uses default eth address when starting sim network * cosmetics * comments failing test * comments failing test * adds orchestrator/ethereum address checks for validators when creating and editing * uses correct error codes for eth/orch address errors * uncomments test and fixes it from commit 434b308 * adds zero eth address check when creating/updating validator * attempts to fix duplicate eth address in sim network * revert squashed changes * uses unwrapped context for msg_server orch/eth validation * increase DefaultGenTxGas to accomodate new qgb validator changes * scaffolds an ethereum address from orchestrator address in staking simulation to have a deterministic way of creating it * fix eth address creation from orch address in operations * increase DefaultGenTxGas * increase DefaultGenTxGas * simpler way of creating an eth address from orch address in operations
Adds to #114